package com.liming.admin.controller;

import com.liming.common.pojo.dto.stock.warehouse.WarehouseAddDTO;
import com.liming.common.pojo.dto.stock.warehouse.WarehousePageQuery;
import com.liming.common.pojo.dto.stock.warehouse.WarehouseUpdateDTO;
import com.liming.common.pojo.vo.PageVO;
import com.liming.common.pojo.vo.stock.warehouse.WarehouseVO;
import com.liming.common.result.LMResult;
import com.liming.stock.client.WarehouseClient;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 *
 * @author liming
 * @date 2025/3/1
 */
@Slf4j
@RestController
@AllArgsConstructor
@Tag(name = "仓库接口-Web")
@RequestMapping("/admin/warehouse")
public class WarehouseController {

    private WarehouseClient warehouseClient;

    @Operation(
            summary = "分页 - 仓库",
            responses = {
            @ApiResponse(responseCode = "1", description = "成功", content = {
                    @Content(mediaType = "application/json", schema = @Schema(implementation = WarehouseVO.class))
            })
    })
    @GetMapping
    public LMResult<PageVO<WarehouseVO>> page(WarehousePageQuery query) {
        return LMResult.success(warehouseClient.page(query));
    }

    @Operation(summary = "新增 - 仓库")
    @PostMapping
    public LMResult<Boolean> add(@RequestBody WarehouseAddDTO warehouseAddDTO) {
        return LMResult.success(warehouseClient.add(warehouseAddDTO));
    }

    @Operation(summary = "更新 - 仓库")
    @PutMapping
    public LMResult<Boolean> update(@RequestBody WarehouseUpdateDTO warehouseUpdDTO) {
        return LMResult.success(warehouseClient.update(warehouseUpdDTO));
    }

    @Operation(summary = "删除 - 仓库")
    @DeleteMapping("{id}")
    public LMResult<Boolean> del(@PathVariable Long id) {
        return LMResult.success(warehouseClient.delete(id));
    }
}
